package com.iciot.service.impl;

import com.iciot.dao.impl.UserDaoImpl;
import com.iciot.domain.User;
import com.iciot.service.UserService;

import java.sql.SQLException;
import java.util.ArrayList;

public class UserServiceImpl implements UserService {
    private UserDaoImpl userDao = new UserDaoImpl();;
    @Override
    public void addUser(User user) throws Exception {
        userDao.insert(user);
    }

    @Override
    public void deleteUser(int id) throws Exception {
        userDao.delete(id);
    }

    @Override
    public void updateUser(User user) throws SQLException {
        userDao.update(user);
    }

    @Override
    public User getById(int id) throws Exception {
        return userDao.findById(id);
    }

    @Override
    public User getByName(String name) throws Exception{
        return userDao.findByName(name);
    }

    @Override
    public ArrayList<User> getAll() throws Exception{
        return userDao.findAll();
    }
}
